package com.jd.ty.pojo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import com.googlecode.jsonplugin.annotations.JSON;

public class Role implements Serializable {

	private static final long serialVersionUID = -130699376089550669L;
	private Long roleId;
	private String roleName;
	private boolean admin;
	private List<Permission> permissions = new ArrayList<Permission>();

	private Long[] permissionIds;
	private String functions="";
	public Role() {

	}

	public Long getRoleId() {
		return roleId;
	}

	public void setRoleId(Long roleId) {
		this.roleId = roleId;
	}

	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	public List<Permission> getPermissions() {
		return permissions;
	}

	public void setPermissions(List<Permission> permissions) {
		this.permissions = permissions;
	}

	public boolean getAdmin() {
		return admin;
	}

	public boolean isAdmin() {
		return admin;
	}

	public void setAdmin(boolean admin) {
		this.admin = admin;
	}
	public String getFunctions() {

		if(admin){
			functions="全部功能";
		}else{
			for (Iterator<Permission> iterator = permissions.iterator(); iterator.hasNext();) {
				Permission p = iterator.next();
				functions=functions+p.getFunction().getFunctionName()+" ";
			}
		}
		return functions;
		
	}

	public Long[] getPermissionIds() {
		return permissionIds;
	}

	public void setPermissionIds(Long[] permissionIds) {
		this.permissionIds = permissionIds;
	}

	public void setFunctions(String functions) {
		this.functions = functions;
	}

}
